<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文件上传</title>
    <style>
        /* 自定义file upload样式 */
        .file-upload {
            display: inline-block;
            border: 2px solid #ccc;
            border-radius: 4px;
            padding: 6px 12px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            transition: border-color 0.3s ease;
        }

        .file-upload:hover {
            border-color: #888;
        }

        /* 隐藏默认的file input */
        .file-input {
            width: 0.1px;
            height: 0.1px;
            opacity: 0;
            overflow: hidden;
            position: absolute;
            z-index: -1;
        }


        .file-label {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            height: 100%;
            cursor: pointer;
        }

        .file-icon {
            font-size: 1.2em; /* 如果你使用Font Awesome图标，请根据需要调整大小 */
        }

        .file-text {
            margin-left: 8px;
        }
    </style>
</head>
<body>
<span onclick="test()">测试</span>
<div class="file-upload">
    <input type="file" id="fileUpload" class="file-input" />
    <label for="fileUpload" class="file-label">
            <span class="file-icon">
                <i class="fas fa-cloud-upload-alt"></i>
            </span>
        <span class="file-text">选择文件上传</span>
    </label>
</div>
<script>
    function test() {
        document.querySelector('#fileUpload').click()
    }
</script>

<!-- 如果你需要Font Awesome图标，请确保在页面中引入它 -->
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> -->
</body>
</html>
